<?php 
class mcategory
{
        private $id;
        private $vi_name;
        private $en_name;
        private $description;
		
        public function get_mcategory($id)
        {
                $m_query = "select * from category_level_1 where id='{$id}'";
                $m_sql = mysql_query($m_query);
                if(isset($m_sql) && mysql_num_rows($m_sql)>0)
                {
                        $m_result = mysql_fetch_assoc($m_sql);
                        $this->id = $m_result['id'];
                        $this->vi_name = $m_result['vi_name'];
                        $this->en_name = $m_result['en_name'];
                        $this->description = $m_result['description'];
                }
        }
		
        public function get_id()
        {
                return $this->id;
        }
        
        public function get_vi_name()
        {
                return $this->vi_name;
        }
        
        public function get_en_name()
        {
                return $this->en_name;
        }
        
        public function get_description()
        {
                return $this->description;
        }

        public function set_id($id)
        {
                $this->id = $id;
        }
        
        public function set_vi_name($vi_name)
        {
                $this->vi_name = $vi_name;
        }
        
        public function set_en_name($en_name)
        {
                $this->en_name = $en_name;
        }
        
        public function set_description($description)
        {
                $this->description = $description;
        }
        
        public function create()
        {
                $m_query = "insert into category_level_1 (vi_name,en_name,description)
                                        values ('{$this->vi_name}','{$this->en_name}','{$this->description}')";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
        
        public function update()
        {
                $m_query = "update category_level_1 
                                        set vi_name='{$this->vi_name}',
											en_name='{$this->en_name}',
                                            description='{$this->description}' 
                                        where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
		
        public function del()
        {
                $m_query = "delete from category_level_1 where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
}

?>